﻿using UnityEngine;
using System.Collections;
using LitJson;

public class KickUnitButton : MonoBehaviour {

	private bool m_submit = false;

	void OnClick()
	{
		MyInfo.Instance.LastSelectedUnitID = 0;
		MyInfo.Instance.LastSelectedUnitDBID = 0;

		if (!m_submit)
		{
			m_submit = true;

//			CSceneManager c = GameObject.FindObjectOfType(typeof(CSceneManager)) as CSceneManager;
			//c.GoToDeckEditScene();
//			c.SubmitUnitChange();
//			RestAPI.singleton.SendMyDeckChangeInfo(ReturnCallback, MyInfo.Instance.MyDeckMap[MyInfo.Instance.MyCurrentDeck].deckId);
			CSceneManager.manager.GoToUnitChangeConfirmScene();
		}
	}
	
	void ReturnCallback(Hashtable returnData)
	{
		switch((RestAPIProtocol)returnData["protocol"])
		{
		case RestAPIProtocol.SENDMYDECKCHANGEINFO:
			RestAPI.singleton.RefreshMyDeckInfo(ReturnCallback);
			break;
		case RestAPIProtocol.REFRESHMYDECKINFO:
			CSceneManager.manager.GoToUnitChangeConfirmScene();
			break;
		}
		
	}
}
